<!-- 物料列表信息 -->
<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-card-body">
      <!-- 头部操作栏 -->
      <div class="layui-form toolbar">
        <div class="layui-form-item lay-query-box">
          <div class="query-lt">
            <div class="layui-form-item layui-row">
              <div class="layui-inline">
                <label class="layui-form-label">物料编码</label>
                <div class="layui-input-inline">
                  <input name="skuCode" class="layui-input" type="text" placeholder="请输入物料编码" />
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">物料名称</label>
                <div class="layui-input-inline">
                  <input name="skuName" class="layui-input" type="text" placeholder="请输入物料名称" />
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">物料规格</label>
                <div class="layui-input-inline">
                  <input name="skuSpec" class="layui-input" type="text" placeholder="请输入物料规格" />
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">物料类型</label>
                <div class="layui-input-inline">
                  <input name="productTypeId" type="hidden" />
                  <div class="layui-input-inline mr0" id="selectProductType"></div>
                </div>
              </div>
            </div>
            <div class="layui-inline">
              <!-- <button class="layui-btn " lay-filter="searchSkuBtn" lay-submit layui-form-keyDownSearch="true" type="button">查询</button>
              <button class="layui-btn  color-white" lay-filter="resetsSkuBtn" lay-submit>重置</button> -->

              <button id="productDetailConfirm" class="layui-btn">确认选择</button>
            </div>
          </div>
          <div class="query-rt">
            <div class="layui-inline">
              <button class="layui-btn icon-btn" lay-filter="searchSkuBtn" lay-submit layui-form-keyDownSearch="true" type="button">查询</button>
              <button class="layui-btn icon-btn color-white" lay-filter="resetsSkuBtn" lay-submit>重置</button>
            </div>
          </div>
        </div>
      </div>
      <!-- 表格 -->
      <div class="scroll-table-4-5">
        <table class="layui-table" id="checkSkuTable" lay-filter="checkSkuTable"></table>
      </div>
    </div>
  </div>
</div>

<!-- js部分 -->
<script>
  layui.use(["layer", "form", "table", "admin"], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
    var table = layui.table;
    var config = layui.config;
    var admin = layui.admin;
    const nowData = { ...parentData };
    const url = nowData.url || "enterprise/product/admin/productDetail/list";
    //物料类型
    admin.initDataSelectTree(true, "enterprise/product/admin/productType/getTreeData", null, "selectProductType", null, "物料类型", "productTypeId", null);
    //订单编号
    let orderId = parentData.orderId;
    // 渲染表格
    // var checkSkuTable = table.render({
    //   elem: "#checkSkuTable",
    //   url: config.base + url,
    //   where: nowData.where || {},
    //   page: nowData.isPage === "" || nowData.isPage === true,
    //   cellMinWidth: 100,
    //   height: "auto",
    //   cols: [
    //     [
    //       // { type: "radio", fixed: "left" },
    //       { type: "checkbox", fixed: "left" },
    //       { field: "skuCode", title: "物料编码", align: "center" },
    //       { field: "skuName", title: "物料名称", align: "center" },
    //       { field: "skuSpec", title: "物料规格", align: "center" },
    //       { field: "productTypeName", title: "物料类型", align: "center" },
    //       { field: "baseUnitName", title: "基础单位", align: "center" },
    //       { field: "mainUnitName", title: "主计量单位", align: "center" },
    //       { field: "productInventoryQuantity", title: "库存数量", align: "center" },
    //       { field: "createTime", title: "创建时间", align: "center" }
    //     ]
    //   ]
    // });
    var checkSkuTable = table.render({
      elem: "#checkSkuTable",
      url: config.base + url,
      where: nowData.where || {},
      page: nowData.isPage === "" || nowData.isPage === true,
      cellMinWidth: 100,
      height: "auto",
      cols: [
        [
          // { type: "radio", fixed: "left" },
          { type: "checkbox", fixed: "left" },
          { field: "skuCode", title: "物料编码", align: "center" },
          { field: "skuName", title: "物料名称", align: "center" },
          { field: "skuSpec", title: "物料规格", align: "center" },
          { field: "productTypeName", title: "物料类型", align: "center" },
          { field: "baseUnitName", title: "基础单位", align: "center" },
          { field: "mainUnitName", title: "主计量单位", align: "center" },
          { field: "productInventoryQuantity", title: "库存数量", align: "center" },
          { field: "createTime", title: "创建时间", align: "center" }
        ]
      ]
    });
    // 搜索
    form.on("submit(searchSkuBtn)", function (data) {
      checkSkuTable.reload(
        {
          where: data.field,
          page: { curr: 1 }
        },
        "data"
      );
    });
    // 重置搜索
    form.on("submit(resetsSkuBtn)", function (data) {
      checkSkuTable.reload({ where: admin.resetSearch(data.field), page: { curr: 1 } }, "data");
    });
    // 确认选择
    $("#productDetailConfirm").click(async function () {
      var checkStatus = table.checkStatus("checkSkuTable");
      if (checkStatus.data.length == 0) {
        layer.msg("请选择一条数据", { icon: 2 });
        return;
      }
      var data = checkStatus.data;
      console.log("data", data);
    });
  });
</script>
